﻿// Scripts 文件
/*
AJAX请求JS封装
编写人：康涛
*/

var httpajax = false;
function createAjax() {
    //开始初始化XMLHttpRequest对象
    if (window.XMLHttpRequest) { //Mozilla 浏览器
        httpajax = new XMLHttpRequest();
        if (httpajax.overrideMimeType) {//设置MiME类别
            httpajax.overrideMimeType("text/xml");
        }
    }
    else if (window.ActiveXObject) { // IE浏览器
        try {
            httpajax = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                httpajax = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }
    if (!httpajax) { // 异常，创建对象实例失败
        window.alert("不能创建XMLHttpRequest对象实例.");
        return false;
    }
}
//POST请求
function callPagePost(myurl, data) {
    createAjax();
    httpajax.open("POST", myurl, false);
    httpajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    httpajax.send(data);
    httpajax.onreadystatechange = function () {
        //如果执行状态成功，那么就把返回信息写到指定的层里
        if (httpajax.readyState == 4 && httpajax.status == 200) {
            //刷新Right框架

            //document.getElementById("lblCurSelected").value = "";
        }
    }
}